import {post, get, dele, put} from '@/utils/serviceHelper.js';

const ORIGINAL_DATA_LIST_LIST = "ORIGINAL_DATA_LIST_LIST";
const state = {
    originalDataList: [],
    originalDataPage: {page: 0, rows: 10, count: 0}
}

const getters = {
    originalDataList(state) {
        return state.originalDataList;
    },
    originalDataPage(state) {
        return state.originalDataPage;
    }
}

const actions = {
    getOriginalDataList({commit, state}, param) {
        get('/riskLog', {...state.originalDataPage, ...param}).then((res) => {
            if (res.code == 0) {
                commit(ORIGINAL_DATA_LIST_LIST, res);
            }
        })
    },
    getParasRiskLogList({commit, state}, param) {
        return new Promise((resolve, reject) => {
            get('/riskLog/paras', param).then((res) => {
                if (res.code == 0) {
                    resolve(res.rs);
                } else {
                    reject(res.messages);
                }
            })
        });
    }
}
const mutations = {
    [ORIGINAL_DATA_LIST_LIST](state, data) {
        state.originalDataList = data.rs;
        state.originalDataPage.count = data.count;
    }
}

export default {
    state,
    getters,
    actions,
    mutations
}
